package com.smart.fourteen.hibernate.base;

import com.smart.fourteen.hibernate.base.dao.TopicDao;
import com.smart.fourteen.hibernate.base.model.Topic;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestSpring {
    public static void main(String[] args) {
        ApplicationContext ac = new ClassPathXmlApplicationContext("com/smart/fourteen/hibernate/base/applicationContext-spring-hibernate.xml");
        TopicDao topicDao = (TopicDao)ac.getBean("topicDao");

        Topic topic = new Topic();
        topic.setName("a");

        topicDao.save(topic);

        Topic getTopic = topicDao.get(2);
        System.out.println(getTopic);

        //topicDao.delete(1);


        long num = topicDao.getTopicNum();
        System.out.println(num);
    }
}
